package com.tw.battle;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.Texture.TextureFilter;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;

public class BattleScreen implements Screen {

	Sprite playerbody;
	Sprite enemybody = null;
	
	Battle battle = new Battle();
	
	int bodyw = (int)(Gdx.graphics.getWidth() / 1.5);
	int bodyh = (int)(Gdx.graphics.getHeight() / 1.5);
	private OrthographicCamera camera;
	private SpriteBatch batch;
	
	int bspritewidth = 256;
	int bspriteheight = 256;
	
	int selfspritex = 300;
	int selfspritey = 300;
	
	int enemyspritex = bodyw-300;
	int enemyspritey = bodyh-300;
	
	public BattleScreen()
	{
		float w = Gdx.graphics.getWidth();
		float h = Gdx.graphics.getHeight();
		camera = new OrthographicCamera(1, h/w);
		batch = new SpriteBatch();
		
		Texture texture = new Texture(Gdx.files.internal("data/boycharbeige.png"));
		texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
		
		TextureRegion region = new TextureRegion(texture, 0, 0, 2048, 4096);
		
		playerbody = new Sprite(region);
		
		playerbody.setSize(0.9f, 0.9f * playerbody.getHeight() / playerbody.getWidth());
		playerbody.setOrigin(playerbody.getWidth()/2, playerbody.getHeight()/2);
		playerbody.setPosition(-playerbody.getWidth()/2, -playerbody.getHeight()/2);
		
	}
	
	@Override
	public void render(float delta) {
		Gdx.gl.glClearColor(1, 1, 1, 1);
		Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
		
		batch.setProjectionMatrix(camera.combined);
		batch.begin();
			playerbody.setPosition(selfspritex, selfspritey);
			playerbody.draw(batch);
		batch.end(); 
		
		
	}
	
	public void step()
	{
		battle.step();
	}

	@Override
	public void resize(int width, int height) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void show() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void hide() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void pause() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void resume() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void dispose() {
		// TODO Auto-generated method stub
		
	}
	
}
